Every decode step, before the kernel runs, vLLM assembles a metadata bundle and hands it over via a scoped context. The model's forward signature never sees it. The dashed orange region is the only place DA touches.
SchedulerOutputwhich reqs run,
how many tokens
→
vLLM metadata path (middleman) — DA hook lives here
BlockTableCPU numpy staging
append_row()
→
commit()H2D copy to
block_table_tensor
→
MetadataBuilderFlashAttentionMetadata
{block_table, seq_lens,
query_start_loc, slot_mapping}
→
set_forward_contextscoped global,
not an argument
→
Attention layerget_attention_context
(layer_name)
→
FlashAttentionImplflash_attn_varlen_func
(…, block_table=…)
The packet cycles left→right. Model code (left of the dashed box, and the layer itself) and the kernel (right) are untouched by DA — the hook rewrites the staged row between append_row() and commit().